<?php

namespace Apps\AppApi\Method\MyBranch;

use Apps\AppApi\Method\BaseMethod;
use PhalconPlus\Api\Common\ResultStatus;
use Apps\Common\Models\AccountBook;
use PhalconPlus\Common\Util;
use Apps\Common\Models\UserBase;
use Apps\Common\Models\BeautyParlor;
use Apps\Common\Libs\SmaUtil;


/**
 * 获取分店列表
 * @author      545
 * @date        2016年3月4日
 * @version     1.1.2
 * @copyright   Copyright 2015 meelier.com
 */
class BranchList extends BaseMethod
{
    

    public function run()
    {
        //验证是否登录
        if(false == $this->verifyUserAuth()){
            return false;
        }
        
        $userid = $this->getUserAuth()->userId;
    	//获取用户账号
    	$mobile = UserBase::findFirst("user_id = {$userid}")->user_account;
//         $mobile = '123456';
    	$smautil = new SmaUtil();
    	$rs = $smautil->getBranch($mobile);
    	
    	if (empty($rs)){
    	    return $this->errorLog(ResultStatus::EMTPYS,"没找到店铺");
    	}
    	
    	foreach ($rs as $k=>$v){
    	    $data[$k]['id'] = $v['shop_id'];
    	    $data[$k]['name'] = $v['shop_name'];
    	}
    	
    	return $this->setResult($data);
    }
    
}